#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
    int n = 0;
    int count = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        int flag = 0;
        int m = i;
        while (m)
        {
            if (m % 10 == 7)
            {
                flag = 1;
            }
            m /= 10;
        }
        if (i % 7 == 0 || flag)
        {
            count++;
        }
    }
    printf("%d", count);
    return 0;
}